home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Source Code
/
C
/
Applications
/
SML⁄NJ 93+
/
Documentation
/
examples
/
quicksort.sml
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
Text File
|
1995-12-30
|
475 b
|
13 lines
|
[
TEXT/R*ch
]
fun quick(le:'a*'a->bool) =
let fun sort [] = []
| sort [x] = [x]
| sort (a::rest) = (* the head "a" is the pivot *)
let fun split(left,right,[]) = sort left @ (a::sort right)
| split(left,right,x::l) =
if le(x,a) then split(x::left,right,l)
else split(left,x::right,l)
in split([],[],rest)
end
in sort
end;